<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>头部</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
    <link rel="stylesheet" href="./css/index.css"/>
    <script src="./js/jquery.js"></script>
    <script src="lib/layer/layer.js"></script>
    <script src="js/base.js"></script>
    <script src="lib/vue/vue.min.js"></script>
    <script src="lib/vue/vue-resource.min.js"></script>
</head>
<body>
   <nav class="top" id="app">
       <div class="topN">
           <div class="logo">
               <img src="./images/top-logo.png" alt=""/><span>优租云</span>
           </div>
           <ul class="nav">
               <a target="main" href="./home.html"><li class="bottom_color">首页</li></a>
               <a target="main" href="./nestCloud.html"><li>优租云</li></a>
               <a target="main" href="./information.html"><li>资讯</li></a>
               <a target="main" href="./aboutUs.html"><li>关于我们</li></a>
               <a target="main" href="./login.html" v-if="info == ''"><li>登录</li></a>
               <a target="main" href="./task_center.html" v-else><li><img :src="info.real_avatar" alt=""/><span class="name">{{info.name}}</span></li></a>
               <li @click="loginOut()">退出</li>
           </ul>
       </div>
   </nav>
</body>
<script>
    (function () {
        var app = new Vue({
            el: '#app',
            data: function () {
                return{
                    task: [],
                    recom: [],
                    news: [],
                    nest: '',
                    info: ''
                }
            },
            mounted: function () {
                this.showData();
//需要执行的方法可以在mounted中进行触发，其获取的数据可以赋到data中后，可以放在前面进行渲染
            },
            methods: {
                showData: function () {
                    let _this = this;
                    get(url + 'user/info', {}).then(
                            function (res) {
                                if (res.body.code == 101) {
                                    tip(res.body.msg);
                                    location.href = './login.html'
                                } else if (res.body.code == 400) {
                                    tip(res.body.msg);
                                } else {
                                    _this.info = res.body.data
                                }
                            }, function (reason) {
                                tip('请求错误')
                            });
                },
                loginOut:function(){
                    logout();
                }
            }
        })
    })()
    $('.nav a li').click(function(){
        $(this).addClass('bottom_color').parent('a').siblings().find('li').removeClass('bottom_color')
    })
</script>
</html>